package com.winchain.chainbill.asset.biz.credit.controller;

import com.shell.bee.base.annotation.Logging;
import com.shell.bee.entity.mvc.RetMsg;
import com.shell.bee.mvc.controller.BaseController;
import com.shell.framework.utils.CommonDataUtil;
import com.winchain.chainbill.asset.biz.credit.service.CreditAssetMgtService;
import java.math.BigDecimal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class CreditAssetMgtController extends BaseController {
	@Autowired
	private CreditAssetMgtService creditAssetMgtService;

	@RequestMapping
	@ResponseBody
	@Logging(module = "������������", methods = "������������")
	public RetMsg distribute(BigDecimal amount, String grpId, String cusId, String currCode) throws Exception {
		String txSnHost = this.creditAssetMgtService.distribute(amount, grpId, CommonDataUtil.getCurEntId(), cusId,
				currCode);

		return new RetMsg("success", true, "����������������", txSnHost);
	}

	@RequestMapping
	@ResponseBody
	@Logging(module = "������������", methods = "��������")
	public RetMsg distributeBatch(String strategy, BigDecimal amount, String grpId, String cusId) throws Exception {
		String[] cusIds = cusId.split(",");
		String txSnHost = this.creditAssetMgtService.distribute(strategy, amount, grpId, CommonDataUtil.getCurEntId(),
				cusIds);

		return new RetMsg("success", true, "������������", txSnHost);
	}

	@RequestMapping
	@ResponseBody
	@Logging(module = "��������", methods = "����/��������")
	public RetMsg optState(String bkpId, String state, String cusId, String remark) {
		String str = this.creditAssetMgtService.updateBkpState(bkpId, state, cusId, remark);
		return new RetMsg("success", true, str);
	}
}
